Skip to content

feat(metrics,logging): address #161 1.4 dogfood follow-up findings - #181

Merged
ncipollina merged 1 commit into
mainfrom
feat/161-dogfood-followup
Nov 12, 2026
Merged

ncipollina merged 1 commit into
mainfrom
feat/161-dogfood-followup

Conversation

@ncipollina

Copy link
Copy Markdown
Contributor

Summary

Addresses the seven usability findings from the #161 1.4 dogfood follow-up, a 231-test xUnit v3 / .NET 11 worker service migrated to 1.4.0-preview.127. Each finding was triaged in RESEARCH-0040. Two are implemented, and the rest are documentation fixes with tested recipes. Nothing changes core composition or provider precedence.

Refs #161 (do not auto-close).

Decisions

# Finding Outcome
1 UseMetrics() loses to UseGeneratedTestDoubles() when registered second Implemented. Compono.Metrics owns IMeterFactory, which is excluded from generated doubles (ADR-0072 Amendment 5)
2 ComposeData binding order / TConfig access Docs. Leading-positional is the contract. The profile registers its config, and the test takes a composed TConfig
3 [Shared] disposables Docs. xUnit v3 JIT already disposes test arguments, and xUnit AOT doesn't. TUnit root-argument disposal is per ADR-0040. No ownership change (ADR-0072 Amendment 6)
4 Metrics checkpoints Deferred. ClearMeasurements() multi-pass pattern documented
5 Category prefixes Implemented. InCategoryPrefix / NotInCategoryPrefix (ADR-0055 Amendment 7)
6 Profile constructor arguments Docs + deferred. Wrapper-profile pattern and single-row ComposeData
7 Migration guide New page: docs/migrating-from-microsoft-extensions-diagnostics-testing.md

Changes

Metrics ownership of IMeterFactory (finding 1)

  • Compono.Generators: a new ComponoMetricsOwnsMeterFactory flag. When it's on, TransitiveClosureWalker.TryRecordTestDouble skips IMeterFactory, the same ownership mechanism as the Logging exclusion (ADR-0055 Amendment 4). The symbol lookup is cached per compilation and only happens when the flag is on.
  • src/Compono.Metrics/build/Compono.Metrics.props (packed to build/ + buildTransitive/) defaults the flag to true. Core Compono.props declares the CompilerVisibleProperty. Consumers can opt out with false.
  • Stage-6 first-registration-wins is unchanged: UseMetrics() must still precede UseNSubstitute()/catch-all providers. The UseMetrics() remarks and the RequireCapturing misuse message now also name UseGeneratedTestDoubles() and the ownership rule.
  • Tradeoff: with the package referenced, UseGeneratedTestDoubles() without UseMetrics() now fails to compose IMeterFactory with a clear CompositionException, instead of producing an uncapturing double. This is documented and tested.

Logging prefix filters (finding 5)

  • LogVerificationBuilder.InCategoryPrefix(string) / NotInCategoryPrefix(string): ordinal, literal prefix (no implied .), and null throws. InCategory is unchanged.

Docs and skill

  • Metrics, Logging, xUnit v3, and xUnit v3 AOT package guides, the profiles and host-logging how-tos, the ComposeData cookbook, troubleshooting, the new migration guide, and the mkdocs nav.
  • skills/compono references for metrics, logging, xunit-v3, and profiles, plus evals 69–74 (new) and corrected evals 39, 66, and 70 (engine-specific disposal).
  • API reference regenerated.

Planning: RESEARCH-0040, ADR-0072 Amendments 5–6, ADR-0055 Amendment 7, PLAN-0075.

Validation

  • dotnet build: 0 warnings, 0 errors.
  • dotnet test (full solution, every TFM): 7,626 total, 0 failed, 501 skipped. A separate xUnit TRX-captured run had 7,062 xUnit tests, 0 failed, 47 TRX files, and no Failed outcomes. TUnit and MSTest TRX runs passed.
  • New tests:
    • MetricsTestDoubleOwnershipTests (generator): flag on/off/unset/unparseable, and a sibling interface is still doubled.
    • MeterFactoryOwnershipTests (runtime, real generated doubles): both registration orders, referenced without UseMetrics(), and fall-through to NSubstitute. With the flag forced off, 3 of the 6 fail, so the regression is real.
    • CategoryPrefixFilterTests.
    • DocumentedRecipeTests (JIT and AOT).
    • MigrationGuideExamplesTests (Logging, Metrics) and MigrationGuideMetricsTests (the BasicUsage sample, exercising the guide's [Compose<MetricsProfile>] example verbatim).
  • test/Compono.Metrics.AotSmokeTest/verify-packaging.sh: PASS, including a new packed-consumer check (UseGeneratedTestDoubles().UseMetrics() gives a CapturingMeterFactory, and the sibling interface gets a generated double).
  • Native AOT publish-and-run (net10.0, osx-arm64): Metrics and Logging smoke tests pass. Compono.XunitV3.Aot.Tests published as AOT: 281 total, 0 failed, and DocumentedRecipeTests 6/6.
  • mkdocs build --strict: clean.
  • Disposal evidence: an empirical probe on xUnit v3 4.0.1 JIT showed a [Shared] IDisposable and an IAsyncDisposable argument both disposed by xUnit after the test, once per argument slot (RESEARCH-0040 finding 3).

Notes for Reviewers

  • Intermittent failure, root-caused and fixed on this branch. MigrationGuideExamplesTests.HostWideCapture_* failed intermittently on net10.0. Its example worker was a BackgroundService, and since .NET 10 ExecuteAsync runs on a background task, so StopAsync could cancel it before it logged. The worker now logs in IHostedService.StartAsync, and the guide notes the caveat. After the fix: 15 targeted reruns across all four TFMs and the full-suite runs above had 0 failures.
  • test/Compono.Metrics.AotSmokeTest/pack-compono.sh now also packs Compono.TestDoubles, for the ownership consumer check. .github/scripts/inspect-packed-nupkgs.sh expects the new props files in Compono.Metrics.nupkg.
  • Compono.Metrics.Tests now enables ComponoGeneratedTestDoubles and references Compono.TestDoubles, so the ownership regressions run against real generated output.
  • Not run: optional external dogfood (scripts/dogfood-validate.sh) and the xUnit 3.2.2 lower-bound rerun.
  • Suggested review focus: the generator exclusion (TransitiveClosureWalker, GeneratorFeatureFlags), the props wiring, and whether any doc still makes an engine-agnostic disposal claim.

Release Notes

  • Compono.Metrics: referencing the package now makes it own IMeterFactory. Compono.TestDoubles no longer generates a double for it, so order against UseGeneratedTestDoubles() doesn't matter. Opt out with <ComponoMetricsOwnsMeterFactory>false</ComponoMetricsOwnsMeterFactory>.
  • Compono.Logging: new InCategoryPrefix / NotInCategoryPrefix verification filters.
  • New guide: migrating from Microsoft.Extensions.Diagnostics.Testing.

🤖 Generated with Claude Code

Resolves the seven usability findings from the #161 dogfood follow-up
(RESEARCH-0040 / PLAN-0075, beads compono-gec):

- Compono.Metrics owns IMeterFactory: a new ComponoMetricsOwnsMeterFactory
  property (defaulted true by Compono.Metrics' packed props) excludes
  IMeterFactory from Compono.TestDoubles generation, so registration order
  against UseGeneratedTestDoubles() no longer matters (ADR-0072 Amendment 5,
  superseding "No generator exclusion is added"). Stage-6
  first-registration-wins is unchanged; UseMetrics() remarks and the misuse
  message now name UseGeneratedTestDoubles() and catch-all providers.
- Compono.Logging: LogVerificationBuilder.InCategoryPrefix and
  NotInCategoryPrefix (ordinal, literal prefix; ADR-0055 Amendment 7).
- Docs only: ComposeData leading-positional binding and reading TConfig via
  a profile registration; per-engine disposal (xUnit v3 JIT disposes test
  arguments, XunitV3.Aot does not; ADR-0072 Amendment 6); ClearMeasurements()
  multi-pass pattern; wrapper-profile pattern for profile constructor
  arguments; new migration guide from Microsoft.Extensions.Diagnostics.Testing.
- Recipes proven by JIT and Native AOT tests; skill references and evals
  updated; API reference regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ncipollina

Copy link
Copy Markdown
Contributor Author

@codex review

Please review commit 5e6db53 (the whole PR, first round). Focus areas:

  1. Generator exclusion (src/Compono.Generators/Discovery/TransitiveClosureWalker.cs, Models/GeneratorFeatureFlags.cs, ComponoIncrementalGenerator.cs): is there any discovery path that records a Compono.TestDoubles double for System.Diagnostics.Metrics.IMeterFactory without going through TryRecordTestDouble? Is the per-compilation symbol cache (BoundedCacheWithFactory) safe for incremental-generator reuse?
  2. Props wiring (src/Compono/build/Compono.props, src/Compono.Metrics/build/Compono.Metrics.props, Compono.Metrics.csproj, .github/scripts/inspect-packed-nupkgs.sh, test/Compono.Metrics.AotSmokeTest/verify-packaging.sh): does the default reach direct AND transitive PackageReference consumers, and does an explicit consumer false always win?
  3. LogVerificationBuilder.InCategoryPrefix / NotInCategoryPrefix: semantics vs. the docs (ordinal, literal prefix, null/empty handling, failure description).
  4. Docs accuracy: any remaining engine-agnostic disposal claim contradicting ADR-0072 Amendment 6 / ADR-0040 (TUnit root-argument disposal), and whether every "compiled example" claim in docs/migrating-from-microsoft-extensions-diagnostics-testing.md is backed by the named test.

@github-actions github-actions Bot added the type: feat New feature label Nov 12, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T02:16:59.588165Z 5e6db53 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 5e6db53b2c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ncipollina
ncipollina merged commit 546af41 into main Nov 12, 2026
21 checks passed
@ncipollina
ncipollina deleted the feat/161-dogfood-followup branch November 12, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant